package com.zero.storage.web;

import com.zero.storage.service.StorageService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zero
 * @ClassName StorageController
 * @Description
 * @Date 2025/5/15 13:37
 */
@RestController
@RequestMapping ("storage")
public class StorageController {
    private final StorageService storageService;

    public StorageController(StorageService storageService) {
        this.storageService = storageService;
    }

    @RequestMapping ("deduct/{commodityCode}/{count}")
    public void deduct(@PathVariable("commodityCode") String commodityCode, @PathVariable("count") int count) {
        storageService.deduct(commodityCode, count);
    }

    @RequestMapping ("refund/{commodityCode}/{count}")
    public void refund(@PathVariable("commodityCode") String commodityCode, @PathVariable("count") int count) {
        storageService.refund(commodityCode, count);
    }
}
